﻿package net.area80.sitemanager.popup
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import net.area80.sitemanager.popup.AbstractPopup;
	
	/**
	* InOutPopup
	* @author Wissarut Pimanmassuriya
	*/
	public class InOutPopup extends AbstractPopup
	{
		private var _needStop:Boolean = false;
		private var shown:Boolean = false;
		private var isInit:Boolean = false;
		
		public function InOutPopup ():void {
				addEventListener(Event.REMOVED_FROM_STAGE, clearUpdate);
				super.stop();
		}

		private function clearUpdate (e:Event=null):void {
				super.stop();
				removeEventListener(Event.REMOVED_FROM_STAGE, clearUpdate);
				removeEventListener(Event.ENTER_FRAME, update);
		}
		public override function stop ():void {
				if(!isInit){
					onInit();
					isInit = true;
				}
				super.stop();
		}
		public override function moveIn ():void {
				gotoAndPlay("in");
		}
		public override function moveOut ():void {
				gotoAndPlay("out");
				addEventListener(Event.ENTER_FRAME, update, false, 0, true);
		}
		private function update (e:Event):void {
				if (currentFrame == totalFrames) {
						super.stop();
						onOut();
						removeEventListener(Event.ENTER_FRAME, update);
				}
		}
		
	}
	
}